package defpackage; import android.net.Uri; import android.text.TextUtils; import com.google.firebase.analytics.FirebaseAnalytics; import com.iflytek.speech.UtilityConfig; import com.mopub.nativeads.MoPubNativeAdPositioning; import defpackage.tax; import defpackage.tbl; import defpackage.tfv; import java.io.File; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.FutureTask; import org.json.JSONException; /* renamed from: syp reason: default package */ public class syp { static final /* synthetic */ boolean $assertionsDisabled = (!syp.class.desiredAssertionStatus()); public vvb gfs; private boolean mStarted; public long uzA; public syl uzB; public tbg uzC; private final tbb uzt; private tbf uzu; private final HashMap<String, WeakReference<tbf>> uzv; public String uzw; public vqb uzx; public vqi uzy; public int uzz; /* access modifiers changed from: package-private */ /* renamed from: syp$a */ public static class a { public static syp uzF = new syp(); } /* access modifiers changed from: package-private */ /* renamed from: syp$b */ public class b { vth uzG = null; b() { } } private syp() { this.mStarted = false; this.uzv = new HashMap<>(); this.uzz = 0; this.uzA = 0; this.uzt = new tbb(); this.uzx = new vqb(); this.uzy = new vqi(); } public static String FW(boolean z) { Uri.Builder buildUpon = Uri.parse(syk.fil().uyX).buildUpon(); if (z) { buildUpon.appendEncodedPath("help/roamingPad.html"); } else { buildUpon.appendEncodedPath("help/roamingMobile.html"); } tfr.a(buildUpon); return buildUpon.toString(); } public static File a(String str, vvb vvb) { szp f; String str2 = syk.fil().uyX; try { if (!tgd.Um(str)) { str = sza.az(syk.fil().uyX, vvb.userId, str); } szo d = syy.d(str2, vvb, str); if (d == null || (f = syz.f(str2, vvb, d.dxl)) == null) { return null; } return szu.b(str2, vvb, f); } catch (Exception e) { e.printStackTrace(); return null; } } private static void a(long j, vrz vrz) { if (vrz instanceof vsd) { tfv.d("public_wpscloud_login_result_fail", j, vrz.getResult()); } else if (!tgb.isNetworkConnected(syo.fio())) { tfv.d("public_wpscloud_login_fail", j, "offline"); } else if (vrz.fUL()) { tfv.d("public_wpscloud_login_fail", j, "socket_timeout" + vrw.h(vrz)); } else if (vrz.fUM()) { tfv.d("public_wpscloud_login_fail", j, "connect_timeout" + vrw.h(vrz)); } else if (vrz.fUN()) { tfv.d("public_wpscloud_login_fail", j, "socket_exception" + vrw.h(vrz)); } else if (vrz.fUO()) { tfv.d("public_wpscloud_login_fail", j, "connect_exception" + vrw.h(vrz)); } else if (vrz.getCode() != 0) { tfv.d("public_wpscloud_login_fail", j, vrw.h(vrz)); } else { tfv.d("public_wpscloud_login_fail", j, vrz.getSimpleName()); } } public static String aW(String str, boolean z) { Uri.Builder buildUpon = Uri.parse(syo.bAz()).buildUpon(); buildUpon.appendEncodedPath("mobile/login"); return t(buildUpon.toString(), str, z); } public static String anA() { return syk.fil().uyX; } private synchronized tbf b(String str, vvb vvb) { tbf tbf; if (vvb != null) { if (!TextUtils.isEmpty(str)) { String format = String.format(Locale.US, "[%s]:[%s]", str, vvb.userId); WeakReference<tbf> weakReference = this.uzv.get(format); tbf = weakReference != null ? weakReference.get() : null; if (tbf == null) { tbf = new tbf(); this.uzv.put(format, new WeakReference<>(tbf)); } } } tbf = null; return tbf; } private static tfd b(vrz vrz) { return vrz instanceof vsd ? new tez(vrz.getResult()) : tfd.e(vrz); } public static tfd c(vrz vrz) { return vrz instanceof vsd ? new tfb(vrz.getResult(), vrz.getMessage()) : tfd.e(vrz); } public static syp fip() { return a.uzF; } public static String getDeviceId() { return tfr.getDeviceId(); } public static List<tau> gz(String str, String str2) { List<taw> gN = tbj.gN(str, str2); ArrayList arrayList = new ArrayList(); if (gN != null) { for (taw taw : gN) { if (taw instanceof tau) { arrayList.add((tau) taw); } } } return arrayList; } public static String t(String str, String str2, boolean z) { Uri.Builder buildUpon = Uri.parse(str).buildUpon(); buildUpon.appendQueryParameter("appid", str2); buildUpon.appendQueryParameter(UtilityConfig.KEY_DEVICE_INFO, z ? "tablet" : "mobile"); buildUpon.appendQueryParameter("isandroidapp", "true"); buildUpon.appendQueryParameter("deviceid", tfr.getDeviceId()); buildUpon.appendQueryParameter("devicename", tgd.getDeviceName()); tfr.a(buildUpon); String str3 = syk.fil().cjL; if (str3 != null) { buildUpon.appendQueryParameter("appname", str3); } String str4 = syk.fil().cjM; if (str4 != null) { buildUpon.appendQueryParameter("appversion", str4); } String str5 = syk.fil().uyZ; if (str5 != null) { buildUpon.appendQueryParameter("appchannel", str5); } buildUpon.appendQueryParameter("platform", tfr.fdF()); buildUpon.appendQueryParameter("platformlanguage", tfr.fdG()); return buildUpon.toString(); } public final synchronized void FX(boolean z) { if (this.uzu != null) { this.uzu.uBy.FY(z); } } public final vsk TA(String str) throws tfd { try { tfv.a aVar = new tfv.a("getAuthedUsers"); vsk WU = this.uzx.wyp.WU(str); aVar.fjx(); return WU; } catch (vrz e) { throw c(e); } } public final vsr TB(String str) throws tfd { try { tfv.a aVar = new tfv.a(FirebaseAnalytics.Event.LOGIN); vsr TB = this.uzx.wyp.TB(str); aVar.fjx(); String str2 = syk.fil().uyX; b(TB.wzS); return TB; } catch (vrz e) { throw c(e); } } public final vvb TC(String str) throws tfd { try { tfv.a aVar = new tfv.a("register"); vvb WV = this.uzx.wyp.WV(str); aVar.fjx(); String str2 = syk.fil().uyX; b(WV); return WV; } catch (vrz e) { throw c(e); } } public final Map<String, String> TD(String str) throws tfd { try { return this.uzx.wyn.TD(str); } catch (vrz e) { throw b(e); } } public final tbc TE(String str) { tax.a aVar = fiq().uBy.uBb.get(str); if (aVar == null) { return null; } return aVar.uBg; } public void Tw(String str) { if (this.uzC != null) { this.uzC.Ua(str); } } public final taw Tx(String str) { return fiq().uBy.TY(str); } public final void Ty(String str) { fiq().uBy.Ty(str); } public final vvb Tz(String str) throws tfd { try { vvb WX = this.uzx.wyo.WX(str); syo.bAz(); b(WX); return WX; } catch (vrz e) { throw b(e); } } public final long a(long j, int i, boolean z, taq<ArrayList<tah>> taq) { tcn tcn = new tcn(j, MoPubNativeAdPositioning.MoPubClientPositioning.NO_REPEAT, z); tcn.a(taq); return fiq().b((tbd) tcn).getId(); } public final long a(String str, String str2, String str3, String str4, String str5, boolean z, boolean z2, taq<String> taq) { tek tek = new tek(str, str2, str3, str4, str5, z, z2); tek.a(taq); return fiq().b((tbd) tek).getId(); } public final long a(String str, String str2, String str3, boolean z, boolean z2, boolean z3, taq<String> taq) { tda tda = new tda(str, str2, str3, z, z2, z3); tda.a(taq); return fiq().b((tbd) tda).getId(); } public final long a(String str, taq<tep> taq) { tdi tdi = new tdi(str); tdi.a(taq); return fiq().b((tbd) tdi).getId(); } public final long a(String str, boolean z, boolean z2, taq<tah> taq) { tct tct = new tct(str, z, z2); tct.a(taq); return fiq().b((tbd) tct).getId(); } public final long a(List<tbl.a> list, tbl.b bVar) { tbl tbl = new tbl(list); tbl.uBO = bVar; return fiq().b((tbd) tbl).getId(); } public final long a(boolean z, long j, int i, boolean z2, taq<ArrayList<tah>> taq) { tbd tcc = z ? new tcc(j, i, z2) : new tcs(j, i, z2); tcc.a(taq); return fiq().b(tcc).getId(); } public vvb a(String str, String str2, String str3, String str4, String str5, boolean z, vrj vrj) throws tfd { tga.i("prepare do third login server=" + str); tga.i("server=" + str + " to checkServerConnected..."); tfy.d("QingService performThirdLogin begin utype=%s, thirdid=%s", str2, str3); long currentTimeMillis = System.currentTimeMillis(); tfv.E("public_wpscloud_login_request", currentTimeMillis); try { tga.i("do third login now..."); vvb b2 = this.uzx.wyo.b(str, str2, str3, str4, str5, z, vrj); tfv.E("public_wpscloud_login_success", currentTimeMillis); return b2; } catch (vrz e) { a(currentTimeMillis, e); String result = e.getResult(); if (result == null) { throw tfd.e(e); } tga.i("login account error : " + result); throw new tez(result); } } public vvb a(String str, String str2, String str3, vrj vrj) throws tfd { tga.i("prepare do login server=" + str); tga.i("server=" + str + " to checkServerConnected..."); tfy.d("QingService performLogin begin account=%s", str2); long currentTimeMillis = System.currentTimeMillis(); tfv.E("public_wpscloud_login_request", currentTimeMillis); try { tga.i("do login now..."); vvb a2 = this.uzx.wyl.a(str2, str3, vrj); tfv.E("public_wpscloud_login_success", currentTimeMillis); return a2; } catch (vrz e) { a(currentTimeMillis, e); String result = e.getResult(); if (result == null) { throw tfd.e(e); } tga.i("login account error : " + result); throw new tez(result); } } public final void a(String str, tas tas) { fiq().uBy.a(str, tas); } public final synchronized void a(vvb vvb) { boolean equals; String str = syk.fil().uyX; String str2 = this.uzw; if (str == str2) { equals = true; } else if (str != null) { equals = str.equals(str2); } else if ($assertionsDisabled || str2 != null) { equals = str2.equals(str); } else { throw new AssertionError(); } if (!equals || vvb != this.gfs) { this.uzw = str; this.gfs = vvb; tbf tbf = this.uzu; if (tbf != null && this.mStarted) { tbf.stop(); } this.uzu = b(str, vvb); if (this.uzu != null) { tbf tbf2 = this.uzu; if (!tbf.$assertionsDisabled && TextUtils.isEmpty(str)) { throw new AssertionError(); } else if (tbf.$assertionsDisabled || vvb != null) { tbf2.uzw = str; tbf2.gfs = vvb; if (this.mStarted) { this.uzu.start(); } } else { throw new AssertionError(); } } } } public final boolean a(vvb vvb, long j) throws tfd { try { this.uzx.wym.G(vvb.lMm, j); return true; } catch (vrz e) { throw c(e); } } public final boolean a(vvb vvb, String str) throws tfd { try { this.uzx.wym.hh(vvb.lMm, str); return true; } catch (vrz e) { throw c(e); } } public final boolean a(vvb vvb, String str, String str2, String str3) throws tfd { try { this.uzx.wym.I(vvb.lMm, str, str2, str3); return true; } catch (vrz e) { throw c(e); } } public final boolean a(vvb vvb, String str, String str2, String str3, String str4) throws tfd { try { this.uzx.wym.m(vvb.lMm, str, str2, str3, str4); return true; } catch (vrz e) { throw c(e); } } public final String av(String str, String str2, String str3) throws tfd { try { tfv.a aVar = new tfv.a("smsVerify"); String a2 = this.uzx.wyp.a(str, str2, str3, false, ""); aVar.fjx(); return a2; } catch (vrz e) { throw c(e); } } public final vvb aw(String str, String str2, String str3) throws tfd { try { tfv.a aVar = new tfv.a("safeRegister"); try { vvb F = vvb.F(this.uzx.bb(str, str2, str3).fUQ()); aVar.fjx(); String str4 = syk.fil().uyX; b(F); return F; } catch (JSONException e) { throw new tfd(e); } } catch (vrz e2) { throw c(e2); } } public final vuw ax(String str, String str2, String str3) throws tfd { String str4 = this.gfs == null ? null : this.gfs.lMm; if (str4 == null) { return null; } try { return this.uzy.wyR.J(str4, str, str2, str3); } catch (vrz e) { throw c(e); } } public final long b(String str, taq<String> taq) { tcm tcm = new tcm(str); tcm.a(taq); return fiq().b((tbd) tcm).getId(); } public final vuv b(String str, String str2, String str3, ArrayList<vux> arrayList) throws tfd { String str4 = this.gfs == null ? null : this.gfs.lMm; if (str4 == null) { return null; } try { return this.uzy.wyR.a(str4, str, str2, str3, arrayList); } catch (vrz e) { throw c(e); } } public final vuy b(String str, String str2, String str3, String str4, String str5, String str6, ArrayList<vux> arrayList) throws tfd { String str7 = this.gfs == null ? null : this.gfs.lMm; if (str7 == null) { return null; } try { return this.uzy.wyR.a(str7, str, str2, str3, str4, str5, str6, arrayList); } catch (vrz e) { throw c(e); } } public final void b(String str, tas tas) { fiq().uBy.b(str, tas); } public void b(final vvb vvb) throws tfd { if (vvb != null) { syk.fil().uzn = vvb.ute; } FutureTask futureTask = new FutureTask(new Callable<b>() { /* class defpackage.syp.AnonymousClass1 */ /* access modifiers changed from: private */ /* renamed from: fiv */ public b call() throws Exception { b bVar = new b(); try { tfv.a aVar = new tfv.a("getVipInfo"); vth WR = syp.this.uzx.wyn.WR(vvb.userId); aVar.fjx(); bVar.uzG = WR; return bVar; } catch (vsd e) { throw new tez(e.result); } catch (vrz e2) { throw tfd.e(e2); } } }); new Thread(futureTask).start(); long currentTimeMillis = System.currentTimeMillis(); vtd vtd = new vtd(); try { tfv.a aVar = new tfv.a("getUserProfile"); vtd.wAj = this.uzx.wyn.WQ(vvb.lMm); aVar.fjx(); try { b bVar = (b) futureTask.get(); if (bVar != null) { vtd.uzG = bVar.uzG; } vvb.wBJ = vtd; tfv.E("public_wpscloud_set_userinfo_success", currentTimeMillis); } catch (ExecutionException e) { Throwable cause = e.getCause(); String str = null; if (cause != null && (cause instanceof tez)) { str = ((tez) cause).result; } if (str != null) { tfv.d("public_wpscloud_set_userinfo_result_fail", currentTimeMillis, str); } else { tfv.E("public_wpscloud_set_userinfo_fail", currentTimeMillis); } if (cause == null || !(cause instanceof tfd)) { throw new tfd(e); } throw ((tfd) cause); } catch (Exception e2) { throw new tfd(e2); } } catch (vsd e3) { throw new tez(e3.result); } catch (vrz e4) { throw b(e4); } } public final boolean b(vvb vvb, String str) throws tfd { try { this.uzx.wym.hi(vvb.lMm, str); return true; } catch (vrz e) { throw c(e); } } public final boolean b(vvb vvb, String str, String str2, String str3, String str4) throws tfd { try { this.uzx.wyp.G(vvb.lMm, this.uzx.wyp.a("", str, str3, str2, str4, "", ""), str, ""); return true; } catch (vrz e) { throw tfd.e(e); } } public final synchronized boolean bBN() { boolean z; if (this.gfs != null) { syk.fil(); z = syk.Tt(this.gfs.userId); } else { z = false; } return z; } public synchronized tay bD(long j) { tay bK; bK = this.uzt.bK(j); if (bK == null && this.uzu != null) { bK = this.uzu.bK(j); } return bK; } public final synchronized boolean bxG() { boolean z; if (this.gfs != null) { syk.fil(); z = syk.Tv(this.gfs.userId); } else { z = false; } return z; } public final String c(String str, String str2, String str3, String str4, String str5, String str6) throws tfd { try { tfv.a aVar = new tfv.a("oauthVerify"); String a2 = this.uzx.wyp.a(str, str2, str3, str4, str5, str6, ""); aVar.fjx(); return a2; } catch (vrz e) { throw c(e); } } public final vtd c(String str, vvb vvb) throws tfd { vtd vtd = new vtd(); try { vtd.wAj = this.uzx.wyn.WQ(vvb.lMm); long j = vtd.wAj.usn; if (j > 0) { try { vtd.gcy = this.uzx.wyn.cm(j); } catch (vsd e) { throw new tez(e.result); } catch (vrz e2) { throw b(e2); } } try { vtd.uzG = this.uzx.wyn.WR(vvb.userId); try { vtb p = new vqg().fUw().p(vvb); vtd.wAk = p; syk.fil().X(p.gcE); } catch (Exception e3) { e3.printStackTrace(); } if (!(!"cn".equals(syr.TH(str)) || vtd.uzG == null || vtd.uzG.wAp == null)) { try { vsu F = this.uzx.wyn.F(syk.fil().uyX, vtd.uzG.wAp.gcC); if (F != null) { vtd.wAl = F; } else { vtd.wAl = null; } } catch (Exception e4) { } } return vtd; } catch (vrz e5) { throw b(e5); } } catch (vsd e6) { throw new tez(e6.result); } catch (vrz e7) { throw b(e7); } } public final synchronized void cancelAll() { this.uzt.cancelAll(); tbf tbf = this.uzu; if (tbf != null) { tbf.cancelAll(); } } public final synchronized tbf fiq() { if (this.uzu == null) { throw new IllegalStateException("must call QingSdk.getConfig().setLoginServer() & QingService.setUserSession() first."); } else if (!this.mStarted) { throw new IllegalStateException("QingService has not started, call QingService.start() first."); } return this.uzu; } public synchronized tbb fir() { if (!this.mStarted) { throw new IllegalStateException("QingService has not started, call QingService.start() first."); } return this.uzt; } public final vsm fis() throws tfd { try { return this.uzx.wyp.WW(this.gfs.lMm); } catch (vrz e) { throw c(e); } } public final vtc fit() throws tfd { try { return this.uzx.wyp.WT(this.gfs.lMm); } catch (vrz e) { throw c(e); } } public final vuz fiu() throws tfd { String str = this.gfs == null ? null : this.gfs.lMm; if (str == null) { return null; } try { return this.uzy.wyR.Xa(str); } catch (vrz e) { throw c(e); } } public final String gu(String str, String str2) throws tfd { try { tfv.a aVar = new tfv.a("verify"); String b2 = this.uzx.wyp.b("", str, str2, false, "", ""); aVar.fjx(); return b2; } catch (vrz e) { throw c(e); } } public final vsz gv(String str, String str2) throws tfd { try { tfv.a aVar = new tfv.a("selectUser"); vsz bc = this.uzx.wyp.bc(str, str2, ""); aVar.fjx(); return bc; } catch (vrz e) { throw c(e); } } public final String gw(String str, String str2) throws tfd { try { tfv.a aVar = new tfv.a("chinaMobileVerify"); String b2 = this.uzx.wyo.b(str, str2, true, ""); aVar.fjx(); return b2; } catch (vrz e) { throw c(e); } } public final boolean gx(String str, String str2) throws tfd { try { this.uzx.wyp.G(this.gfs.lMm, str, str2, ""); return true; } catch (vrz e) { throw tfd.e(e); } } public final String gy(String str, String str2) throws tfd { try { tfv.a aVar = new tfv.a("getThirdPartyLoginUrl"); String H = this.uzx.wyo.H(str, "verify", "https://account.wps.cn/v1/verifycallbackapp", str2); aVar.fjx(); return H; } catch (vrz e) { throw b(e); } } public final synchronized void lj(boolean z) { if (this.gfs != null) { syk.fil().aV(this.gfs.userId, z); } } public final String rD(String str) { String str2 = fiq().uzw; try { return (String) new vqg().fUr().a(fiq().gfs, false, vqe.WJ(str2), str).bSM.get("url"); } catch (Exception e) { e.printStackTrace(); return null; } } public final boolean rG(String str) { return fiq().uBy.Tx(str) != null; } public final long rH(String str) { taw TY = fiq().uBy.TY(str); if (TY != null) { return TY.getId(); } return 0; } public final String rJ(String str) { return !tgd.Um(str) ? str : sza.ay(syk.fil().uyX, fiq().gfs.userId, str); } public final String rK(String str) throws tfd { try { return this.uzx.wyn.hf(this.gfs.lMm, str); } catch (vrz e) { throw c(e); } } public final String rw(String str) throws tfd { try { return this.uzx.wyo.H(str, null, null, ""); } catch (vrz e) { throw b(e); } } public final synchronized void start() { if (!this.mStarted) { this.uzt.start(); if (this.uzu != null) { this.uzu.start(); } this.mStarted = true; } } public final synchronized void stop() { if (this.mStarted) { if (this.uzu != null) { this.uzu.stop(); } this.uzt.stop(); this.mStarted = false; } } }